﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="Test.aspx.cs" Inherits="lists_Administration_Catalog_Test" %>

<asp:Content ID="Content1" ContentPlaceHolderID="body" runat="Server">
    <script src="<%= ResolveUrl("~/scripts/plupload/moxie.min.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveUrl("~/scripts/plupload/plupload.full.min.js") %>" type="text/javascript"></script>
      <link href="<%= ResolveUrl("~/styles/chosen/chosen.min.css") %>" rel="stylesheet"
        type="text/css" />

    <script language="javascript" type="text/javascript">
        $(document).ready(function () {

            var uploader = new plupload.Uploader({
                runtimes: 'html5,flash,silverlight',
                browse_button: 'pickfiles',
                container: 'container',
                max_file_size: '5mb',
                url: '<%= ResolveUrl("~/ajaxhandler/administration/catalog/Positionhandler.ashx") %>' + '?method=insert',
                flash_swf_url: '<%= ResolveUrl("~/scripts/plupload/Moxie.swf") %>',
                silverlight_xap_url: '<%= ResolveUrl("~/scripts/plupload/Moxie.xap") %>',
                filters: [

                 { title: "Excel files", extensions: "xls,xlsx" },
                 { title: "Csv files", extensions: "csv" }
		],
                resize: { width: 320, height: 240, quality: 90 }
            });

            uploader.bind('Init', function (up, params) {

                var msg = 'Untuk dapat melakukan proses unggah / upload dokumen, browser anda harus mendukung salah satu teknologi, HTML 5 / Flash / Silverlight';

                if (params.runtime == 'html5') {
                    msg = '';
                } else if (params.runtime == 'flash') {
                    msg = '';
                } else if (params.runtime == 'silverlight') {
                    msg = ''
                }

                if (msg != '') {
                    alert(msg);
                }

            });

            uploader.init();

            uploader.bind('FilesAdded', function (up, files) {

                if (up.files.length > 1) {
                    alert('Hanya diperbolehkan satu file untuk di upload!');
                    return false;
                }

                $.each(files, function (i, file) {
                    $('#filelist').append(
                        '<div id="' + file.id + '">' + file.name + ' (' + plupload.formatSize(file.size) + ') <b></b>' + '</div>');
                });


                up.refresh(); // Reposition Flash/Silverlight
            });

            uploader.bind('FileUploaded', function (up, file, info) {

                var err = JSON.parse(info.response);
                alert(err.Message);

            });

            uploader.bind('Error', function (up, err) {

                var errMsg = '';

                switch (err.code) {
                    case (-600):
                        errMsg = 'File tidak boleh lebih dari 5 Mb';
                        break;
                    case (-601):
                        errMsg = 'File harus berformat excel / csv';
                        break;
                    default:
                        errMsg = err.code + ' - ' + err.message;
                        break;
                }

                alert(errMsg);

                up.refresh(); // Reposition Flash/Silverlight

            });

        });

    </script>
    <div class="side-content fr">
        <div class="content-module">
            <div class="content-module-heading cf">
                <h3 class="fl">
                    Upload Data Master</h3>
                <span class="fr expand-collapse-text">Click to collapse</span> <span class="fr expand-collapse-text initial-expand">
                    Click to expand</span>
            </div>
            <!-- end content-module-heading -->
            <div class="content-module-main">
                <div>
                    <table border="0">
                        <tr>
                            <td>
                                Modul
                            </td>
                            <td>
                                :
                            </td>
                            <td>
                                <asp:DropDownList ID="ddlModul" runat="server" Width="200">
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td valign="top">
                                File
                            </td>
                            <td valign="top">
                                :
                            </td>
                            <td>
                                <div id="container">
                                    <a id="pickfiles" class="plupload_button plupload_add ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary"
                                        href="#"><span class="ui-button-icon-primary ui-icon ui-icon-circle-plus" /><span
                                            class="ui-button-text">Add Files</span> </a>
                                    <br />
                                    <div id="filelist">
                                    </div>
                                    <ul class="uploads">
                                        <!-- Will be populated dynamically with LI/IMG tags. -->
                                    </ul>
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
                <br />
            </div>
            <!-- end content-module-main -->
        </div>
    </div>
</asp:Content>
